{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "dc1f4b2d-f44d-48be-849d-c7b4e261719d",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import asyncio\n",
    "from langchain_core.documents import Document\n",
    "import openai\n",
    "import nest_asyncio\n",
    "from langchain.text_splitter import CharacterTextSplitter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "567ff4e7-94c5-4124-87c6-d546fe6da787",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain_elasticsearch import ElasticsearchStore\n",
    "from langchain_openai import OpenAIEmbeddings\n",
    "import elasticsearch\n",
    "import getpass\n",
    "from functools import partial\n",
    "from datasets import load_dataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "6105b2da-0fa9-4b98-a70a-682ad73b5497",
   "metadata": {},
   "outputs": [],
   "source": [
    "nest_asyncio.apply()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "4609d5d8-d5dd-4937-b125-6962f740c772",
   "metadata": {},
   "outputs": [],
   "source": [
    "ds = load_dataset(\"ELiRF/dacsa\", \"spanish\", token=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "8d7e7583-b35a-4792-a530-5de64af1c548",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatasetDict({\n",
       "    train: Dataset({\n",
       "        features: ['id', 'summary', 'article'],\n",
       "        num_rows: 1802919\n",
       "    })\n",
       "    validation: Dataset({\n",
       "        features: ['id', 'summary', 'article'],\n",
       "        num_rows: 104052\n",
       "    })\n",
       "    test.i: Dataset({\n",
       "        features: ['id', 'summary', 'article'],\n",
       "        num_rows: 104052\n",
       "    })\n",
       "    test.ni: Dataset({\n",
       "        features: ['id', 'summary', 'article'],\n",
       "        num_rows: 109626\n",
       "    })\n",
       "})"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ds"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "2069765a-3d29-47a1-86f0-0c91ffb23a7f",
   "metadata": {},
   "outputs": [],
   "source": [
    "def parse_data(ds):\n",
    "    df = ds[\"train\"].to_pandas()\n",
    "    return df.sample(n=25)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "db9e7eac-b9ca-44d0-af03-369ffdfc8b17",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>summary</th>\n",
       "      <th>article</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>778201</th>\n",
       "      <td>1a6d7e2a3a46ccb0134763068b9cc694ed5efb72243f95...</td>\n",
       "      <td>Uno de los cuatro asaltantes al templo metodis...</td>\n",
       "      <td>Ocho personas han muerto y otras 44 han result...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1441437</th>\n",
       "      <td>990b015fee4b21d566abd9913877c2e59b157064ec1654...</td>\n",
       "      <td>Más de 100.000 personas cumplen los criterios ...</td>\n",
       "      <td>El borrador del plan nacional contra la hepati...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1330621</th>\n",
       "      <td>9d7400d837c79f953f61094c73ffa99cf2e81fcab6a6d2...</td>\n",
       "      <td>En una serie de tuits, el creador de Tesla aug...</td>\n",
       "      <td>Elon Musk, el padre del Hyperloop, de los coch...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14390</th>\n",
       "      <td>86d5787b89b15b08e4c9b32b24f204a8c5b4143ab5c18c...</td>\n",
       "      <td>El líder de Podemos afirma que se nota otra re...</td>\n",
       "      <td>Pablo Iglesias, líder de Podemos, ha emplazado...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>334827</th>\n",
       "      <td>e9ac2ce03b1a81039aadae9c8d4f9b6fc68174746294e4...</td>\n",
       "      <td>Tom MacMaster, estadounidense de 40 años, escr...</td>\n",
       "      <td>Tom MacMaster, el estadounidense de 40 años qu...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                        id  \\\n",
       "778201   1a6d7e2a3a46ccb0134763068b9cc694ed5efb72243f95...   \n",
       "1441437  990b015fee4b21d566abd9913877c2e59b157064ec1654...   \n",
       "1330621  9d7400d837c79f953f61094c73ffa99cf2e81fcab6a6d2...   \n",
       "14390    86d5787b89b15b08e4c9b32b24f204a8c5b4143ab5c18c...   \n",
       "334827   e9ac2ce03b1a81039aadae9c8d4f9b6fc68174746294e4...   \n",
       "\n",
       "                                                   summary  \\\n",
       "778201   Uno de los cuatro asaltantes al templo metodis...   \n",
       "1441437  Más de 100.000 personas cumplen los criterios ...   \n",
       "1330621  En una serie de tuits, el creador de Tesla aug...   \n",
       "14390    El líder de Podemos afirma que se nota otra re...   \n",
       "334827   Tom MacMaster, estadounidense de 40 años, escr...   \n",
       "\n",
       "                                                   article  \n",
       "778201   Ocho personas han muerto y otras 44 han result...  \n",
       "1441437  El borrador del plan nacional contra la hepati...  \n",
       "1330621  Elon Musk, el padre del Hyperloop, de los coch...  \n",
       "14390    Pablo Iglesias, líder de Podemos, ha emplazado...  \n",
       "334827   Tom MacMaster, el estadounidense de 40 años qu...  "
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "subset_df = parse_data(ds)\n",
    "subset_df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "c19cced1-bcf0-4f63-ba8d-589eca4fcda6",
   "metadata": {},
   "outputs": [],
   "source": [
    "async def translate_text(text):\n",
    "    document = Document(page_content=text)\n",
    "    loop = asyncio.get_event_loop()\n",
    "    response = await loop.run_in_executor(\n",
    "        None,\n",
    "        partial(\n",
    "            openai.chat.completions.create,\n",
    "            model=\"gpt-4o\",\n",
    "            messages=[\n",
    "                {\"role\": \"system\", \"content\": \"You are a translator.\"},\n",
    "                {\n",
    "                    \"role\": \"user\",\n",
    "                    \"content\": f\"Translate the following text to English: {document.page_content}\",\n",
    "                },\n",
    "            ],\n",
    "        ),\n",
    "    )\n",
    "    translated_text = response.choices[0].message.content.strip()\n",
    "    return translated_text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "fa3f4cce-9f05-4db5-a2ed-4dc6298c0c3a",
   "metadata": {},
   "outputs": [],
   "source": [
    "async def translate_dataframe(df, column_name1, column_name2):\n",
    "    tasks_column1 = [translate_text(text) for text in df[column_name1]]\n",
    "    tasks_column2 = [translate_text(text) for text in df[column_name2]]\n",
    "\n",
    "    translated_texts1 = await asyncio.gather(*tasks_column1)\n",
    "    translated_texts2 = await asyncio.gather(*tasks_column2)\n",
    "\n",
    "    df[\"translated_\" + column_name1] = translated_texts1\n",
    "    df[\"translated_\" + column_name2] = translated_texts2\n",
    "\n",
    "    return df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "dcc64c66-c5ba-4d46-9177-08f1f36737c3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>summary</th>\n",
       "      <th>article</th>\n",
       "      <th>translated_summary</th>\n",
       "      <th>translated_article</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>778201</th>\n",
       "      <td>1a6d7e2a3a46ccb0134763068b9cc694ed5efb72243f95...</td>\n",
       "      <td>Uno de los cuatro asaltantes al templo metodis...</td>\n",
       "      <td>Ocho personas han muerto y otras 44 han result...</td>\n",
       "      <td>One of the four assailants at the Methodist te...</td>\n",
       "      <td>Eight people died and another 44 were injured ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1441437</th>\n",
       "      <td>990b015fee4b21d566abd9913877c2e59b157064ec1654...</td>\n",
       "      <td>Más de 100.000 personas cumplen los criterios ...</td>\n",
       "      <td>El borrador del plan nacional contra la hepati...</td>\n",
       "      <td>More than 100,000 people meet the criteria for...</td>\n",
       "      <td>The draft of the national plan against hepatit...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1330621</th>\n",
       "      <td>9d7400d837c79f953f61094c73ffa99cf2e81fcab6a6d2...</td>\n",
       "      <td>En una serie de tuits, el creador de Tesla aug...</td>\n",
       "      <td>Elon Musk, el padre del Hyperloop, de los coch...</td>\n",
       "      <td>In a series of tweets, the creator of Tesla pr...</td>\n",
       "      <td>Elon Musk, the father of Hyperloop, Tesla auto...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14390</th>\n",
       "      <td>86d5787b89b15b08e4c9b32b24f204a8c5b4143ab5c18c...</td>\n",
       "      <td>El líder de Podemos afirma que se nota otra re...</td>\n",
       "      <td>Pablo Iglesias, líder de Podemos, ha emplazado...</td>\n",
       "      <td>The leader of Podemos states that there is a n...</td>\n",
       "      <td>Pablo Iglesias, leader of Podemos, has called ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>334827</th>\n",
       "      <td>e9ac2ce03b1a81039aadae9c8d4f9b6fc68174746294e4...</td>\n",
       "      <td>Tom MacMaster, estadounidense de 40 años, escr...</td>\n",
       "      <td>Tom MacMaster, el estadounidense de 40 años qu...</td>\n",
       "      <td>Tom MacMaster, a 40-year-old American, was wri...</td>\n",
       "      <td>Tom MacMaster, the 40-year-old American who ha...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40366</th>\n",
       "      <td>a0caae74f42c4f0f2c2037ec38e2c2b74db46746ddc1ee...</td>\n",
       "      <td>El rodaje comenzará el 16 de agosto en pueblos...</td>\n",
       "      <td>La serie de televisión Águila Roja que emite T...</td>\n",
       "      <td>Filming will begin on August 16 in towns of Ma...</td>\n",
       "      <td>The television series Águila Roja, which airs ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1628056</th>\n",
       "      <td>7be0bb718118c80312cddb07181cd5144c79354905adfc...</td>\n",
       "      <td>El plan con mejor acogida ha sido el de mejora...</td>\n",
       "      <td>Jóvenes mayores de 16 años votan qué inversion...</td>\n",
       "      <td>The most well-received plan has been the impro...</td>\n",
       "      <td>Young people over the age of 16 vote on their ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>389664</th>\n",
       "      <td>025449f042134e89631c21cb34d59399174ccce2f6721d...</td>\n",
       "      <td>Tanto los tanques como las esferas fueron cons...</td>\n",
       "      <td>La compañía Repsol Butano ha iniciado el desmo...</td>\n",
       "      <td>Both the tanks and the spheres were constructe...</td>\n",
       "      <td>The company Repsol Butano has begun the disman...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>176264</th>\n",
       "      <td>3c3ce4dbdd18fd5e2836e4fc98ce20f74c46294a473947...</td>\n",
       "      <td>A estos hombres se les han intervenido cerca d...</td>\n",
       "      <td>Ocho personas, cinco rumanos, dos españoles y ...</td>\n",
       "      <td>These men have had approximately 90 meters of ...</td>\n",
       "      <td>Eight people, five Romanians, two Spaniards, a...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>401423</th>\n",
       "      <td>e988e55eaa6906835e2743c924dc4d03976b1aff22a805...</td>\n",
       "      <td>Varios monumentos, como los castillos de Galve...</td>\n",
       "      <td>“Estamos en una de las provincias con más cast...</td>\n",
       "      <td>Several monuments, such as the castles of Galv...</td>\n",
       "      <td>\"We are in one of the provinces with the most ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1742837</th>\n",
       "      <td>3d4a210a73193653a48b5ae34aa64bc0a4c7062016753a...</td>\n",
       "      <td>En el «negocio familiar» participaban todos lo...</td>\n",
       "      <td>La Policía Nacional ha desarticulado un clan f...</td>\n",
       "      <td>In the \"family business,\" all the members part...</td>\n",
       "      <td>The National Police have dismantled a family c...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1172888</th>\n",
       "      <td>17b868c8fc8629e447b39affb79b6efd425cc2f19df760...</td>\n",
       "      <td>La Plataforma d'Afectats per les Hipoteques ac...</td>\n",
       "      <td>El juzgado de Primera Instancia número 12 de V...</td>\n",
       "      <td>The Platform for People Affected by Mortgages ...</td>\n",
       "      <td>The Court of First Instance No. 12 of Valencia...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>237603</th>\n",
       "      <td>00e23a70e025dd43e76bc5a9c76e45005ce5e68b4b7e6d...</td>\n",
       "      <td>El exceso de regalos puede anestesiar la fanta...</td>\n",
       "      <td>El exceso de regalos puede anestesiar la fanta...</td>\n",
       "      <td>The excess of gifts can numb the imagination o...</td>\n",
       "      <td>The excess of gifts can anesthetize children's...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>588533</th>\n",
       "      <td>34a3f4bfc6ba6cc38c6b11510c3d156bb902c0961a1273...</td>\n",
       "      <td>El App Trade Centre reúne en su segunda edició...</td>\n",
       "      <td>Valencia, tecnología y cultura digital ya no e...</td>\n",
       "      <td>The App Trade Centre brings together leading c...</td>\n",
       "      <td>Valencia, technology, and digital culture are ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>308355</th>\n",
       "      <td>4f1c87bfde7ba33ff4e100cc351fd33cd92564f718a0b4...</td>\n",
       "      <td>La temperatura en el suburbano llegó a 36,6 en...</td>\n",
       "      <td>“Próxima parada: Passeig de Gràcia”. Un montón...</td>\n",
       "      <td>The temperature in the subway reached 36.6 deg...</td>\n",
       "      <td>Next Stop: Passeig de Gràcia. A bunch of passe...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8402</th>\n",
       "      <td>cbdba0d04ce2c700ce93b5fb679997e570dc831057eed1...</td>\n",
       "      <td>Saxofonista, compositor, empresario en sus rat...</td>\n",
       "      <td>Saxofonista, compositor, empresario en sus rat...</td>\n",
       "      <td>Saxophonist, composer, entrepreneur in his spa...</td>\n",
       "      <td>Saxophonist, composer, entrepreneur in his spa...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>164872</th>\n",
       "      <td>cf8aadf378f0e5e49f1c4c02b291144977d090a8eb61bc...</td>\n",
       "      <td>La organización subraya que en Mallorca sigue ...</td>\n",
       "      <td>n Familias que se ven obligadas a ocupar viven...</td>\n",
       "      <td>The organization emphasizes that in Mallorca, ...</td>\n",
       "      <td>Families that are forced to occupy other peopl...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>743738</th>\n",
       "      <td>8ae05d0bf680a83aca94f8bd630a6d48ba0f7871817a85...</td>\n",
       "      <td>El presidente defiende a la justicia española ...</td>\n",
       "      <td>En pleno caos del Brexit, un asunto que protag...</td>\n",
       "      <td>The president defends the Spanish justice syst...</td>\n",
       "      <td>In the midst of the Brexit chaos, a matter tha...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>810611</th>\n",
       "      <td>4a459f61128c2a4fa1ecd3085125ce4d2d70da6f2dec67...</td>\n",
       "      <td>´Pizzi nos está metiendo mucha caña e intensid...</td>\n",
       "      <td>El centrocampista del Valencia Míchel Herrero ...</td>\n",
       "      <td>\"Pizzi is pushing us really hard and with a lo...</td>\n",
       "      <td>The Valencia midfielder Míchel Herrero indicat...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1008019</th>\n",
       "      <td>e8d0b3574cd016b441a492c7a5b63717a74f7f82e72812...</td>\n",
       "      <td>“Debemos actuar para ayudar a los más vulnerab...</td>\n",
       "      <td>El actor Robert de Niro ha hecho un llamamient...</td>\n",
       "      <td>\"We must act to help the most vulnerable,\" say...</td>\n",
       "      <td>The actor Robert de Niro has called on all cou...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>65830</th>\n",
       "      <td>4fb2a9cc30310e5dd09d6de60b87f64aa24d873ae4e4c0...</td>\n",
       "      <td>La empresa ha adquirido la participación del 8...</td>\n",
       "      <td>CaixaBank ha adquirido la participación del 8,...</td>\n",
       "      <td>The company has acquired an 8.4% stake in Grup...</td>\n",
       "      <td>CaixaBank has acquired an 8.4% stake in BPI Gr...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>447124</th>\n",
       "      <td>a46bd5e026fdd4d135dfb823b9d92297aba4edb21c415d...</td>\n",
       "      <td>En concreto se contemplan los tramos: Barcelon...</td>\n",
       "      <td>La ministra de Fomento, Ana Pastor, ha anuncia...</td>\n",
       "      <td>Specifically, the following sections are consi...</td>\n",
       "      <td>The Minister of Development, Ana Pastor, annou...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>143458</th>\n",
       "      <td>5894dd5863fdbc6c6e4e101b9ed1ef6ffb12491b059887...</td>\n",
       "      <td>Un reciente estudio afirma que estos milenario...</td>\n",
       "      <td>Su misterio ha durado más de un siglo, y podrí...</td>\n",
       "      <td>A recent study claims that these ancient chalk...</td>\n",
       "      <td>Its mystery has lasted more than a century, an...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>680981</th>\n",
       "      <td>87c69cf023d6b70634300b2521ab5279607971e11149f6...</td>\n",
       "      <td>Lucho, el defensa del Segorbe insultado por ra...</td>\n",
       "      <td>Luciano Mutasi Mba, Lucho para la gente del fú...</td>\n",
       "      <td>Lucho, the Segorbe defender who was insulted w...</td>\n",
       "      <td>Luciano Mutasi Mba, known as Lucho to football...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>984837</th>\n",
       "      <td>aad22bb8b867ceb70655ad128c19cf882d02ec5f4a45b9...</td>\n",
       "      <td>Murillo fue contratado como vigilante del Cent...</td>\n",
       "      <td>El francotirador detenido y encarcelado por su...</td>\n",
       "      <td>Murillo was hired as a security guard at the T...</td>\n",
       "      <td>The sniper arrested and imprisoned for his int...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                        id  \\\n",
       "778201   1a6d7e2a3a46ccb0134763068b9cc694ed5efb72243f95...   \n",
       "1441437  990b015fee4b21d566abd9913877c2e59b157064ec1654...   \n",
       "1330621  9d7400d837c79f953f61094c73ffa99cf2e81fcab6a6d2...   \n",
       "14390    86d5787b89b15b08e4c9b32b24f204a8c5b4143ab5c18c...   \n",
       "334827   e9ac2ce03b1a81039aadae9c8d4f9b6fc68174746294e4...   \n",
       "40366    a0caae74f42c4f0f2c2037ec38e2c2b74db46746ddc1ee...   \n",
       "1628056  7be0bb718118c80312cddb07181cd5144c79354905adfc...   \n",
       "389664   025449f042134e89631c21cb34d59399174ccce2f6721d...   \n",
       "176264   3c3ce4dbdd18fd5e2836e4fc98ce20f74c46294a473947...   \n",
       "401423   e988e55eaa6906835e2743c924dc4d03976b1aff22a805...   \n",
       "1742837  3d4a210a73193653a48b5ae34aa64bc0a4c7062016753a...   \n",
       "1172888  17b868c8fc8629e447b39affb79b6efd425cc2f19df760...   \n",
       "237603   00e23a70e025dd43e76bc5a9c76e45005ce5e68b4b7e6d...   \n",
       "588533   34a3f4bfc6ba6cc38c6b11510c3d156bb902c0961a1273...   \n",
       "308355   4f1c87bfde7ba33ff4e100cc351fd33cd92564f718a0b4...   \n",
       "8402     cbdba0d04ce2c700ce93b5fb679997e570dc831057eed1...   \n",
       "164872   cf8aadf378f0e5e49f1c4c02b291144977d090a8eb61bc...   \n",
       "743738   8ae05d0bf680a83aca94f8bd630a6d48ba0f7871817a85...   \n",
       "810611   4a459f61128c2a4fa1ecd3085125ce4d2d70da6f2dec67...   \n",
       "1008019  e8d0b3574cd016b441a492c7a5b63717a74f7f82e72812...   \n",
       "65830    4fb2a9cc30310e5dd09d6de60b87f64aa24d873ae4e4c0...   \n",
       "447124   a46bd5e026fdd4d135dfb823b9d92297aba4edb21c415d...   \n",
       "143458   5894dd5863fdbc6c6e4e101b9ed1ef6ffb12491b059887...   \n",
       "680981   87c69cf023d6b70634300b2521ab5279607971e11149f6...   \n",
       "984837   aad22bb8b867ceb70655ad128c19cf882d02ec5f4a45b9...   \n",
       "\n",
       "                                                   summary  \\\n",
       "778201   Uno de los cuatro asaltantes al templo metodis...   \n",
       "1441437  Más de 100.000 personas cumplen los criterios ...   \n",
       "1330621  En una serie de tuits, el creador de Tesla aug...   \n",
       "14390    El líder de Podemos afirma que se nota otra re...   \n",
       "334827   Tom MacMaster, estadounidense de 40 años, escr...   \n",
       "40366    El rodaje comenzará el 16 de agosto en pueblos...   \n",
       "1628056  El plan con mejor acogida ha sido el de mejora...   \n",
       "389664   Tanto los tanques como las esferas fueron cons...   \n",
       "176264   A estos hombres se les han intervenido cerca d...   \n",
       "401423   Varios monumentos, como los castillos de Galve...   \n",
       "1742837  En el «negocio familiar» participaban todos lo...   \n",
       "1172888  La Plataforma d'Afectats per les Hipoteques ac...   \n",
       "237603   El exceso de regalos puede anestesiar la fanta...   \n",
       "588533   El App Trade Centre reúne en su segunda edició...   \n",
       "308355   La temperatura en el suburbano llegó a 36,6 en...   \n",
       "8402     Saxofonista, compositor, empresario en sus rat...   \n",
       "164872   La organización subraya que en Mallorca sigue ...   \n",
       "743738   El presidente defiende a la justicia española ...   \n",
       "810611   ´Pizzi nos está metiendo mucha caña e intensid...   \n",
       "1008019  “Debemos actuar para ayudar a los más vulnerab...   \n",
       "65830    La empresa ha adquirido la participación del 8...   \n",
       "447124   En concreto se contemplan los tramos: Barcelon...   \n",
       "143458   Un reciente estudio afirma que estos milenario...   \n",
       "680981   Lucho, el defensa del Segorbe insultado por ra...   \n",
       "984837   Murillo fue contratado como vigilante del Cent...   \n",
       "\n",
       "                                                   article  \\\n",
       "778201   Ocho personas han muerto y otras 44 han result...   \n",
       "1441437  El borrador del plan nacional contra la hepati...   \n",
       "1330621  Elon Musk, el padre del Hyperloop, de los coch...   \n",
       "14390    Pablo Iglesias, líder de Podemos, ha emplazado...   \n",
       "334827   Tom MacMaster, el estadounidense de 40 años qu...   \n",
       "40366    La serie de televisión Águila Roja que emite T...   \n",
       "1628056  Jóvenes mayores de 16 años votan qué inversion...   \n",
       "389664   La compañía Repsol Butano ha iniciado el desmo...   \n",
       "176264   Ocho personas, cinco rumanos, dos españoles y ...   \n",
       "401423   “Estamos en una de las provincias con más cast...   \n",
       "1742837  La Policía Nacional ha desarticulado un clan f...   \n",
       "1172888  El juzgado de Primera Instancia número 12 de V...   \n",
       "237603   El exceso de regalos puede anestesiar la fanta...   \n",
       "588533   Valencia, tecnología y cultura digital ya no e...   \n",
       "308355   “Próxima parada: Passeig de Gràcia”. Un montón...   \n",
       "8402     Saxofonista, compositor, empresario en sus rat...   \n",
       "164872   n Familias que se ven obligadas a ocupar viven...   \n",
       "743738   En pleno caos del Brexit, un asunto que protag...   \n",
       "810611   El centrocampista del Valencia Míchel Herrero ...   \n",
       "1008019  El actor Robert de Niro ha hecho un llamamient...   \n",
       "65830    CaixaBank ha adquirido la participación del 8,...   \n",
       "447124   La ministra de Fomento, Ana Pastor, ha anuncia...   \n",
       "143458   Su misterio ha durado más de un siglo, y podrí...   \n",
       "680981   Luciano Mutasi Mba, Lucho para la gente del fú...   \n",
       "984837   El francotirador detenido y encarcelado por su...   \n",
       "\n",
       "                                        translated_summary  \\\n",
       "778201   One of the four assailants at the Methodist te...   \n",
       "1441437  More than 100,000 people meet the criteria for...   \n",
       "1330621  In a series of tweets, the creator of Tesla pr...   \n",
       "14390    The leader of Podemos states that there is a n...   \n",
       "334827   Tom MacMaster, a 40-year-old American, was wri...   \n",
       "40366    Filming will begin on August 16 in towns of Ma...   \n",
       "1628056  The most well-received plan has been the impro...   \n",
       "389664   Both the tanks and the spheres were constructe...   \n",
       "176264   These men have had approximately 90 meters of ...   \n",
       "401423   Several monuments, such as the castles of Galv...   \n",
       "1742837  In the \"family business,\" all the members part...   \n",
       "1172888  The Platform for People Affected by Mortgages ...   \n",
       "237603   The excess of gifts can numb the imagination o...   \n",
       "588533   The App Trade Centre brings together leading c...   \n",
       "308355   The temperature in the subway reached 36.6 deg...   \n",
       "8402     Saxophonist, composer, entrepreneur in his spa...   \n",
       "164872   The organization emphasizes that in Mallorca, ...   \n",
       "743738   The president defends the Spanish justice syst...   \n",
       "810611   \"Pizzi is pushing us really hard and with a lo...   \n",
       "1008019  \"We must act to help the most vulnerable,\" say...   \n",
       "65830    The company has acquired an 8.4% stake in Grup...   \n",
       "447124   Specifically, the following sections are consi...   \n",
       "143458   A recent study claims that these ancient chalk...   \n",
       "680981   Lucho, the Segorbe defender who was insulted w...   \n",
       "984837   Murillo was hired as a security guard at the T...   \n",
       "\n",
       "                                        translated_article  \n",
       "778201   Eight people died and another 44 were injured ...  \n",
       "1441437  The draft of the national plan against hepatit...  \n",
       "1330621  Elon Musk, the father of Hyperloop, Tesla auto...  \n",
       "14390    Pablo Iglesias, leader of Podemos, has called ...  \n",
       "334827   Tom MacMaster, the 40-year-old American who ha...  \n",
       "40366    The television series Águila Roja, which airs ...  \n",
       "1628056  Young people over the age of 16 vote on their ...  \n",
       "389664   The company Repsol Butano has begun the disman...  \n",
       "176264   Eight people, five Romanians, two Spaniards, a...  \n",
       "401423   \"We are in one of the provinces with the most ...  \n",
       "1742837  The National Police have dismantled a family c...  \n",
       "1172888  The Court of First Instance No. 12 of Valencia...  \n",
       "237603   The excess of gifts can anesthetize children's...  \n",
       "588533   Valencia, technology, and digital culture are ...  \n",
       "308355   Next Stop: Passeig de Gràcia. A bunch of passe...  \n",
       "8402     Saxophonist, composer, entrepreneur in his spa...  \n",
       "164872   Families that are forced to occupy other peopl...  \n",
       "743738   In the midst of the Brexit chaos, a matter tha...  \n",
       "810611   The Valencia midfielder Míchel Herrero indicat...  \n",
       "1008019  The actor Robert de Niro has called on all cou...  \n",
       "65830    CaixaBank has acquired an 8.4% stake in BPI Gr...  \n",
       "447124   The Minister of Development, Ana Pastor, annou...  \n",
       "143458   Its mystery has lasted more than a century, an...  \n",
       "680981   Luciano Mutasi Mba, known as Lucho to football...  \n",
       "984837   The sniper arrested and imprisoned for his int...  "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "loop = asyncio.get_event_loop()\n",
    "loop.run_until_complete(translate_dataframe(subset_df, \"summary\", \"article\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "5db4572c-ab44-4818-ae2b-4ef44719144d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>summary</th>\n",
       "      <th>article</th>\n",
       "      <th>translated_summary</th>\n",
       "      <th>translated_article</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>778201</th>\n",
       "      <td>1a6d7e2a3a46ccb0134763068b9cc694ed5efb72243f95...</td>\n",
       "      <td>Uno de los cuatro asaltantes al templo metodis...</td>\n",
       "      <td>Ocho personas han muerto y otras 44 han result...</td>\n",
       "      <td>One of the four assailants at the Methodist te...</td>\n",
       "      <td>Eight people died and another 44 were injured ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1441437</th>\n",
       "      <td>990b015fee4b21d566abd9913877c2e59b157064ec1654...</td>\n",
       "      <td>Más de 100.000 personas cumplen los criterios ...</td>\n",
       "      <td>El borrador del plan nacional contra la hepati...</td>\n",
       "      <td>More than 100,000 people meet the criteria for...</td>\n",
       "      <td>The draft of the national plan against hepatit...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1330621</th>\n",
       "      <td>9d7400d837c79f953f61094c73ffa99cf2e81fcab6a6d2...</td>\n",
       "      <td>En una serie de tuits, el creador de Tesla aug...</td>\n",
       "      <td>Elon Musk, el padre del Hyperloop, de los coch...</td>\n",
       "      <td>In a series of tweets, the creator of Tesla pr...</td>\n",
       "      <td>Elon Musk, the father of Hyperloop, Tesla auto...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14390</th>\n",
       "      <td>86d5787b89b15b08e4c9b32b24f204a8c5b4143ab5c18c...</td>\n",
       "      <td>El líder de Podemos afirma que se nota otra re...</td>\n",
       "      <td>Pablo Iglesias, líder de Podemos, ha emplazado...</td>\n",
       "      <td>The leader of Podemos states that there is a n...</td>\n",
       "      <td>Pablo Iglesias, leader of Podemos, has called ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>334827</th>\n",
       "      <td>e9ac2ce03b1a81039aadae9c8d4f9b6fc68174746294e4...</td>\n",
       "      <td>Tom MacMaster, estadounidense de 40 años, escr...</td>\n",
       "      <td>Tom MacMaster, el estadounidense de 40 años qu...</td>\n",
       "      <td>Tom MacMaster, a 40-year-old American, was wri...</td>\n",
       "      <td>Tom MacMaster, the 40-year-old American who ha...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                        id  \\\n",
       "778201   1a6d7e2a3a46ccb0134763068b9cc694ed5efb72243f95...   \n",
       "1441437  990b015fee4b21d566abd9913877c2e59b157064ec1654...   \n",
       "1330621  9d7400d837c79f953f61094c73ffa99cf2e81fcab6a6d2...   \n",
       "14390    86d5787b89b15b08e4c9b32b24f204a8c5b4143ab5c18c...   \n",
       "334827   e9ac2ce03b1a81039aadae9c8d4f9b6fc68174746294e4...   \n",
       "\n",
       "                                                   summary  \\\n",
       "778201   Uno de los cuatro asaltantes al templo metodis...   \n",
       "1441437  Más de 100.000 personas cumplen los criterios ...   \n",
       "1330621  En una serie de tuits, el creador de Tesla aug...   \n",
       "14390    El líder de Podemos afirma que se nota otra re...   \n",
       "334827   Tom MacMaster, estadounidense de 40 años, escr...   \n",
       "\n",
       "                                                   article  \\\n",
       "778201   Ocho personas han muerto y otras 44 han result...   \n",
       "1441437  El borrador del plan nacional contra la hepati...   \n",
       "1330621  Elon Musk, el padre del Hyperloop, de los coch...   \n",
       "14390    Pablo Iglesias, líder de Podemos, ha emplazado...   \n",
       "334827   Tom MacMaster, el estadounidense de 40 años qu...   \n",
       "\n",
       "                                        translated_summary  \\\n",
       "778201   One of the four assailants at the Methodist te...   \n",
       "1441437  More than 100,000 people meet the criteria for...   \n",
       "1330621  In a series of tweets, the creator of Tesla pr...   \n",
       "14390    The leader of Podemos states that there is a n...   \n",
       "334827   Tom MacMaster, a 40-year-old American, was wri...   \n",
       "\n",
       "                                        translated_article  \n",
       "778201   Eight people died and another 44 were injured ...  \n",
       "1441437  The draft of the national plan against hepatit...  \n",
       "1330621  Elon Musk, the father of Hyperloop, Tesla auto...  \n",
       "14390    Pablo Iglesias, leader of Podemos, has called ...  \n",
       "334827   Tom MacMaster, the 40-year-old American who ha...  "
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "subset_df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "d6ea4160-2409-4748-b4f6-26904291ddd6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "Host:  ········\n",
      "API Key:  ········\n"
     ]
    }
   ],
   "source": [
    "es_client = elasticsearch.Elasticsearch(\n",
    "    getpass.getpass(\"Host: \"),\n",
    "    api_key=getpass.getpass(\"API Key: \"),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "8b26e6b5-c710-46d3-a59c-8516dc9bcd00",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Deleted existing index: vs-post-data\n",
      "Created new index: vs-post-data\n"
     ]
    }
   ],
   "source": [
    "index_name = \"vs-post-data\"\n",
    "\n",
    "# Check if the index exists using keyword argument\n",
    "if es_client.indices.exists(index=index_name):\n",
    "    es_client.indices.delete(index=index_name)\n",
    "    print(f\"Deleted existing index: {index_name}\")\n",
    "\n",
    "# Create a new index using keyword argument\n",
    "es_client.indices.create(index=index_name)\n",
    "print(f\"Created new index: {index_name}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "5b3ba2a3-a4e9-4b7a-9f33-290b2ad3bd11",
   "metadata": {},
   "outputs": [],
   "source": [
    "embedding = OpenAIEmbeddings(model=\"text-embedding-3-large\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "94dd529f-5e02-420a-9aba-2459ef2f4ec6",
   "metadata": {},
   "outputs": [],
   "source": [
    "elastic_vector_search = ElasticsearchStore(\n",
    "    index_name=\"vs-post-data\",\n",
    "    es_connection=es_client,\n",
    "    embedding=embedding,\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "aa295a28-cb5d-4d15-97a5-764234cc8d47",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Created a chunk of size 7007, which is longer than the specified 5000\n"
     ]
    }
   ],
   "source": [
    "translated_texts = subset_df[\"translated_article\"].tolist()\n",
    "combined_text = \"\\n\".join(translated_texts)\n",
    "text_splitter = CharacterTextSplitter(chunk_size=5000, chunk_overlap=50)\n",
    "docs = text_splitter.split_documents([Document(page_content=combined_text)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "035a4592-d59b-42a2-8faa-92e758939ac8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['612f958b-a830-4f39-8d25-2b408c1778cc',\n",
       " 'e227a8b6-7e7b-491c-b93f-aca4291d3eda',\n",
       " '5fa946f1-1dd8-491a-a142-55e2cab21507',\n",
       " '2101e7be-8889-48e3-a32d-eecd8ed21659',\n",
       " '4f7a5fa8-4c0d-4976-ae63-28dc03e8a60d',\n",
       " 'f6b2b0a5-355a-409f-8d85-16b839df790d',\n",
       " '574ae78e-617d-49b6-884b-23ba8676965d',\n",
       " 'f181ac6d-9703-4691-b53f-ca24b0dfd1dd',\n",
       " '1949df0d-c438-4ff3-9710-daa0563f4d23',\n",
       " 'cc704289-a1dc-461e-a052-72cfe56edb33',\n",
       " '91a84211-6481-4c50-8c01-bdea90c5be32',\n",
       " '6a5a2dac-051f-44ef-81e7-858f9732a3d9',\n",
       " '8cde9f07-40e1-417d-a585-c80688ac1d6a',\n",
       " '525fbb94-bb42-44f5-9d41-2c1c5b95d825',\n",
       " '6b434e53-f863-4862-a250-383ebd799446',\n",
       " '53ca83bf-71e2-4f22-9698-5575e92ad914',\n",
       " '697d193d-e8f8-4d21-9a57-66d1ee0942d6',\n",
       " 'bc5fe419-914c-4919-a7bc-485e73240225',\n",
       " '6d9c7b6f-8cdc-494b-aaea-76ed0edeee3d',\n",
       " '55710340-557c-4d73-9ce8-a6641fbeceac',\n",
       " 'dd5dd83f-d655-4a8a-aa9a-cba454b4bdf6',\n",
       " 'dd1f74cd-b2a3-4567-9ac5-cbb8da578c2b']"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "elastic_vector_search.add_documents(docs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "d216c2a5-5c6c-4848-83e1-49e6ccce625f",
   "metadata": {},
   "outputs": [],
   "source": [
    "query = \"What happened in Spain?\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "a08c9a02-f7ce-4e99-a434-f2ecf509efff",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[Document(page_content='Post-October 1st, the sniper worked during November and until December 21st in the security support teams in an annex space of the CTTI that was set up due to the parliamentary election call. The Department of Digital Policies has requested an informative report today from Enerpro S.L. to gather more information on this matter. The man, who sought logistical support in a WhatsApp chat to commit the assassination, remains in prison by order of a court in Terrassa (Barcelona), in a case open for the crimes of conspiracy to commit attacks against the head of government and possession, storage of illegal arms, ammunition, and explosives, as well as another hate crime. Murillo was arrested on September 19th by the Mossos d\\'Esquadra, a few days after receiving a complaint from a local Vox leader in Barcelona, who had received his WhatsApp messages stating that he was willing to \"sacrifice\" himself for Spain and wanted to kill Sánchez as revenge for his intention to exhume Franco from the Valley of the Fallen.'),\n",
       " Document(page_content='Each May since 2006, the association has organized the \"March of Flowers,\" advocating for their heritage by placing protest bouquets at the site. In 2016, the Junta supported seven archaeological projects in Guadalajara, totaling aid just shy of 72,000 euros. These include the Cenomanian vertebrate complex in Algora, the Castil de Griegos Celtiberian fort in Checa, the Virgin de la Muela hill in Driebes, and the Recópolis site in Zorita de los Canes. The Junta is also committed to ongoing research at the Caraca site in Driebes, potentially the first Roman city discovered in Guadalajara.\\n\\n\"The administration\\'s support for archaeological efforts is commendable, but a long-term plan with economic backing is needed to prioritize the architectural heritage needs,” emphasizes Raúl Conde, also head of the Castle of Galve Association. \"In Castilla y León, historical heritage investment topped 500 million euros from 2004 to 2012 with over 5,400 interventions. We lack comparable data for Castilla-La Mancha, but it’s surely far less.\"\\n\\nThe Castle of Galve de Sorbe exemplifies persistent heritage advocacy in Guadalajara. The association has worked tirelessly for over a decade to secure this 15th-century monument, constructed by the Estúñiga family. The castle is in severe disrepair, with neglected interiors and deteriorating exteriors severely affecting its keep.\\n\\nGovernmental and private pressures to comply with conservation laws regarding the Bien de Interés Cultural designation have led to the first heritage infringement case in Guadalajara: private owner Enrique Calle Pinker must pay a 72,000-euro fine and present a restoration project. Both the association and the Galve town hall hope this serves to enforce maintenance and ensure the castle\\'s preservation.\\n\\nSuch apathy and negligence extend beyond Galve. Many of Guadalajara\\'s fifty castles are private, with varying states of care – some meticulously restored, others insensitively altered, and most neglected. Spectacular castles like Riba de Santiuste and Pelegrina are spiraling towards ruin. Prominent sites like the Gothic church of San Francisco de Atienza and the monasteries of La Salceda de Tendilla, the Querencia church, ancient bridges, the Peña Escrita de Channels, or the Villaflores village near Guadalajara city also languish without public investment.\\n\\nJournalist Manu Leguineche, familiar with Guadalajara’s intricacies, wrote in \\'The Club of Affectionate Shortfall,\\' recently reissued: \"The trend is towards graceless modern construction while hundreds of castles fall to dust. I wonder what the US would do with these treasures—they might not escape poor taste but would rise from their ashes.” Castles, forgotten churches, and monasteries in Guadalajara await their resurrection, hoping to emerge from dust due to a blend of neglect, insensitivity, and lack of resources.\\nThe National Police have dismantled a family clan known as \"La Chelo\", based in Castellón, which had become one of the networks controlling cocaine trafficking in the Levante region, and have arrested eleven of its members. In a statement, the National Police reported that all members of the \"family business\" participated with different roles, led by the matriarch \"La Chelo\", a 53-year-old Spanish national. The woman, well known in the criminal realm, had been arrested 28 times previously and had become a stronghold in the Castellón area following the police dismantling of other families. According to police sources, this clan handled the supply of cocaine and heroin to the Perpetuo Socorro group and \"Extramuros de Poniente\", where \"Chelo\" had her headquarters. \\n\\nIn the first phase of the operation, police actions focused on a subdivision of the clan responsible for acquiring cocaine by the kilogram, which they then distributed to other family members. These members would \"prepare\" the drug with cutting agents to increase profits and sold it retail. When they were about to conduct an exchange, police agents thwarted the action, seizing a kilo of cocaine, nearly 27,000 euros in cash, three luxury cars, and a stolen and loaded firearm. Five people were arrested in this operation, but one of the suspects, Chelo\\'s son J.M.B, well-known to police for prior drug trafficking arrests in 2003, 2006, and 2007 and currently pending trial, escaped and remains at large.\\n\\nThe second phase of the operation targets the branch of the organization dedicated to direct consumer sales and small-scale distribution to other families supplied by them, aiming to conclude the police operation. Four home searches were conducted, three in Almazora and one at Chelo\\'s house in Extramuros, leading to six arrests and the seizure of 600 grams of cocaine, 24 grams of heroin, several precision scales, wires, plastics, cutting agents, nearly 7,000 euros in cash, and a high-caliber stolen revolver pending checks for involvement in other crimes.'),\n",
       " Document(page_content='The percentage of Spanish nationals being helped has also decreased to 44% of the total, while 51% are non-EU foreigners from over 70 countries. Most of these foreigners have regularized their stay, but 12.4% are in irregular situations and 1.4% are undocumented. Another concern raised by Càritas is the continued rejection many immigrants face on the island. \\n\\nBy age, most of the Càritas users are between 30 and 50 years old. Regarding family types, more than 45% were couples with children, 16.4% were single-parent families, and 24% were individuals living alone. Last year, Càritas Mallorca, which will receive one of the 5yc94 awards on the 29th, addressed over 35,000 requests. The effort and commitment of almost a thousand volunteers and staff were highlighted.\\n\\nAs a new initiative for 2017, work is being done on creating a labor reintegration enterprise, initially focusing on the reuse of secondhand clothing, which could offer contracts lasting up to three years.\\nIn the midst of the Brexit chaos, a matter that had taken center stage in a fierce debate in the European Parliament shortly before, Pedro Sánchez’s arrival at the Strasbourg Hemicycle on Wednesday marked a radical shift with a speech full of European enthusiasm. So much so that several spokespersons, even from rival groups, appreciated this tone of defense of Europe, which is increasingly less common. Sánchez aimed to focus the debate on defending the European Union against totalitarianism and the extreme right, and received widespread support. However, the session became much more contentious as the issue of Catalonia came to the fore. Several MEPs asked him to do something to free the “procés” prisoners, whom some defined as \"political prisoners.\" Several Catalan pro-independence leaders who are imprisoned are well-known in the European Parliament because they were once members. A number of posters with their photos, splashed in yellow, punctuated the dominant blue of the enormous Strasbourg hemicycle. \\n\\nMORE INFORMATION       \\nApplause for Sánchez, Casado, and Rivera       \\nSánchez will request equality policies and a common unemployment insurance in Europe      \\nThe PSOE tests PP and Cs with motions against sexism throughout Spain  \\n\\nAccompanied by Josep Borrell, who presided over this Parliament (2004-2007), Sánchez did not want to talk about Catalonia — although he was forced to do so — but rather about Europe and the success of anti-Europeanism. “For Europe to protect us, it is our duty to protect Europe,” the president proclaimed as a key idea. Sánchez delivered several messages against the extreme right, precisely on the same day when a government in Andalusia was being formed with the support of Vox, which was mentioned in speeches by several MEPs, not only the Spanish ones. \"Forgetting history is a luxury we cannot afford. We are facing an authoritarianism that thrives on invented nostalgia. There is no worse nostalgia than longing for what never happened,\" he cited, referring to Joaquín Sabina. \"In the face of regression, progress. The past will never be the future of our societies; it is a place from which to learn from our mistakes. They want to destroy the EU because of the values it upholds. At specific moments in our history, to resist is to advance,\" Sánchez asserted, referring to his political biography, which began with a job for the UN in Bosnia, to explain his Europeanism. \"Peace and democracy cannot be taken for granted. I saw it in Sarajevo. The rise of these anti-European forces threatens our integration project and influences the agenda. I urge us not to be dragged by this force and its siren songs. They only pursue the goal of destroying Europe. I am not worried about the far-right but about how it is influencing the discourse of parties that previously wanted to strengthen the EU. Therefore, I propose protecting Europe so that Europe can protect our citizens,\" he concluded.'),\n",
       " Document(page_content='The spheres are made of carbon steel, and three of them are covered with thermal insulation (primarily polyurethane foam, a common insulator even in construction) to allow for the storage of refrigerated propane inside. These three insulated spheres will be scrapped due to the high cost of dismantling their insulation, while the others are being dismantled and transported to a company in another country. According to Repsol, the dismantling work is being carried out following the group\\'s safety standards by a specialized Spanish company. The team responsible for these tasks consists of a minimum workforce of four people, including a safety manager and a site manager, though for special operations the team is reinforced with more experienced personnel in the use of machinery and the removal of asbestos cement, among other tasks.\\n\\nA prestigious engineering firm is in charge of safety coordination and supervision, while Repsol personnel from the Escombreras LPG plant (Murcia) and engineering and maintenance supervisors oversee the work and material removal.\\nEight people, five Romanians, two Spaniards, and one Bulgarian, have been arrested in a single day after being caught red-handed attempting to steal copper cable at two locations in the city of Alicante. According to a statement from the National Police Corps, these men were found with nearly 90 meters of cable and numerous tools, including two sledgehammers, three crowbars, four hoes, three pliers, two screwdrivers, a pickaxe, a shovel, and a generator.\\n\\nThe first incident occurred on the 15th when five men (one of them a minor) were arrested while inside a warehouse in the industrial area of Aguamarga, digging a trench in the parcel\\'s ground to access and steal copper cable. At that moment, they had cut about one and a half meters of the cable and had an additional seven meters of trench exposed. They were found with approximately 40 meters of copper cable and numerous tools, such as two sledgehammers, three crowbars, four hoes, pliers, a pickaxe, a shovel, and a generator.\\n\\nJust a few hours later, another three individuals were caught by a police patrol stealing copper in several buildings under construction in Cabo de las Huertas. Upon noticing the police presence, the suspects attempted to flee but were immediately intercepted and arrested. They were found with various tools used to cut and prepare the copper cable for subsequent sale and about 50 meters of copper cable.\\n\\nAll the detainees have been put at the disposal of the Alicante duty court, except for the minor who was released.\\n\"We are in one of the provinces with the most castles in Spain, but also in one where restoration support is lacking.\" These words were spoken many years ago by the late professor José Luis García de Paz, a heritage researcher and one of the leading specialists in this field. It remains a statement that reflects the neglect in which a large part of the historical and artistic heritage of the province of Guadalajara lies.\\n\\nThe Parador of Sigüenza, established in 1976 in the castle of this town; the Museum of the Alcarria Journey, located in the Templar castle of Torija; the Casa del Doncel, in Sigüenza; the Romanesque church of Labros, in the Lordship of Molina; the Tower of Aragon in Molina; or the walls of Atienza, rehabilitated with state funds, are some exceptions in the catalog of restored historical assets in Guadalajara. Also included are the rural Romanesque hermitages, especially those in the Sierra Norte, and other singular monuments such as the castle of Jadraque, the Ducal Palace of Pastrana, the Romanesque churches of Brihuega, the cathedral of Sigüenza, or the historic center of Hita in the heart of the Alcarria. However, due to Guadalajara\\'s dense history, the province\\'s heritage encompasses dozens of architectural assets, especially in small villages, still awaiting attention from administrations.\\n\\nOrtega y Gasset, who explored the Castile of Guadalajara in the early 20th century and documented the monuments possessed by its villages, admired something in the Germans that he missed in Spain: respect for the past. Little progress has been made since then, as evidenced by the \\'Red List of Heritage,\\' annually updated by the Hispania Nostra association. Castilla-La Mancha is, after Castilla y León, the autonomous community with the most monuments on this list: 72 in total, of which 23 are in Guadalajara. These include significant sites such as the castles of Galve de Sorbe, Pelegrina, or Riba de Santiuste in the Sierra Norte, but also the church of San Francisco de Atienza – the only example of English Gothic in Guadalajara – and the monasteries of Bonaval in Retiendas; Santa María de Óvila in Trillo; San Salvador in Pinilla de Jadraque; and Sopetrán in the heart of the Alcarria.')]"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "results = elastic_vector_search.similarity_search(query)\n",
    "results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "f087b15c-71d1-4132-8c6a-c7f65480ac01",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[Document(page_content='Post-October 1st, the sniper worked during November and until December 21st in the security support teams in an annex space of the CTTI that was set up due to the parliamentary election call. The Department of Digital Policies has requested an informative report today from Enerpro S.L. to gather more information on this matter. The man, who sought logistical support in a WhatsApp chat to commit the assassination, remains in prison by order of a court in Terrassa (Barcelona), in a case open for the crimes of conspiracy to commit attacks against the head of government and possession, storage of illegal arms, ammunition, and explosives, as well as another hate crime. Murillo was arrested on September 19th by the Mossos d\\'Esquadra, a few days after receiving a complaint from a local Vox leader in Barcelona, who had received his WhatsApp messages stating that he was willing to \"sacrifice\" himself for Spain and wanted to kill Sánchez as revenge for his intention to exhume Franco from the Valley of the Fallen.'),\n",
       " Document(page_content='Each May since 2006, the association has organized the \"March of Flowers,\" advocating for their heritage by placing protest bouquets at the site. In 2016, the Junta supported seven archaeological projects in Guadalajara, totaling aid just shy of 72,000 euros. These include the Cenomanian vertebrate complex in Algora, the Castil de Griegos Celtiberian fort in Checa, the Virgin de la Muela hill in Driebes, and the Recópolis site in Zorita de los Canes. The Junta is also committed to ongoing research at the Caraca site in Driebes, potentially the first Roman city discovered in Guadalajara.\\n\\n\"The administration\\'s support for archaeological efforts is commendable, but a long-term plan with economic backing is needed to prioritize the architectural heritage needs,” emphasizes Raúl Conde, also head of the Castle of Galve Association. \"In Castilla y León, historical heritage investment topped 500 million euros from 2004 to 2012 with over 5,400 interventions. We lack comparable data for Castilla-La Mancha, but it’s surely far less.\"\\n\\nThe Castle of Galve de Sorbe exemplifies persistent heritage advocacy in Guadalajara. The association has worked tirelessly for over a decade to secure this 15th-century monument, constructed by the Estúñiga family. The castle is in severe disrepair, with neglected interiors and deteriorating exteriors severely affecting its keep.\\n\\nGovernmental and private pressures to comply with conservation laws regarding the Bien de Interés Cultural designation have led to the first heritage infringement case in Guadalajara: private owner Enrique Calle Pinker must pay a 72,000-euro fine and present a restoration project. Both the association and the Galve town hall hope this serves to enforce maintenance and ensure the castle\\'s preservation.\\n\\nSuch apathy and negligence extend beyond Galve. Many of Guadalajara\\'s fifty castles are private, with varying states of care – some meticulously restored, others insensitively altered, and most neglected. Spectacular castles like Riba de Santiuste and Pelegrina are spiraling towards ruin. Prominent sites like the Gothic church of San Francisco de Atienza and the monasteries of La Salceda de Tendilla, the Querencia church, ancient bridges, the Peña Escrita de Channels, or the Villaflores village near Guadalajara city also languish without public investment.\\n\\nJournalist Manu Leguineche, familiar with Guadalajara’s intricacies, wrote in \\'The Club of Affectionate Shortfall,\\' recently reissued: \"The trend is towards graceless modern construction while hundreds of castles fall to dust. I wonder what the US would do with these treasures—they might not escape poor taste but would rise from their ashes.” Castles, forgotten churches, and monasteries in Guadalajara await their resurrection, hoping to emerge from dust due to a blend of neglect, insensitivity, and lack of resources.\\nThe National Police have dismantled a family clan known as \"La Chelo\", based in Castellón, which had become one of the networks controlling cocaine trafficking in the Levante region, and have arrested eleven of its members. In a statement, the National Police reported that all members of the \"family business\" participated with different roles, led by the matriarch \"La Chelo\", a 53-year-old Spanish national. The woman, well known in the criminal realm, had been arrested 28 times previously and had become a stronghold in the Castellón area following the police dismantling of other families. According to police sources, this clan handled the supply of cocaine and heroin to the Perpetuo Socorro group and \"Extramuros de Poniente\", where \"Chelo\" had her headquarters. \\n\\nIn the first phase of the operation, police actions focused on a subdivision of the clan responsible for acquiring cocaine by the kilogram, which they then distributed to other family members. These members would \"prepare\" the drug with cutting agents to increase profits and sold it retail. When they were about to conduct an exchange, police agents thwarted the action, seizing a kilo of cocaine, nearly 27,000 euros in cash, three luxury cars, and a stolen and loaded firearm. Five people were arrested in this operation, but one of the suspects, Chelo\\'s son J.M.B, well-known to police for prior drug trafficking arrests in 2003, 2006, and 2007 and currently pending trial, escaped and remains at large.\\n\\nThe second phase of the operation targets the branch of the organization dedicated to direct consumer sales and small-scale distribution to other families supplied by them, aiming to conclude the police operation. Four home searches were conducted, three in Almazora and one at Chelo\\'s house in Extramuros, leading to six arrests and the seizure of 600 grams of cocaine, 24 grams of heroin, several precision scales, wires, plastics, cutting agents, nearly 7,000 euros in cash, and a high-caliber stolen revolver pending checks for involvement in other crimes.'),\n",
       " Document(page_content='The percentage of Spanish nationals being helped has also decreased to 44% of the total, while 51% are non-EU foreigners from over 70 countries. Most of these foreigners have regularized their stay, but 12.4% are in irregular situations and 1.4% are undocumented. Another concern raised by Càritas is the continued rejection many immigrants face on the island. \\n\\nBy age, most of the Càritas users are between 30 and 50 years old. Regarding family types, more than 45% were couples with children, 16.4% were single-parent families, and 24% were individuals living alone. Last year, Càritas Mallorca, which will receive one of the 5yc94 awards on the 29th, addressed over 35,000 requests. The effort and commitment of almost a thousand volunteers and staff were highlighted.\\n\\nAs a new initiative for 2017, work is being done on creating a labor reintegration enterprise, initially focusing on the reuse of secondhand clothing, which could offer contracts lasting up to three years.\\nIn the midst of the Brexit chaos, a matter that had taken center stage in a fierce debate in the European Parliament shortly before, Pedro Sánchez’s arrival at the Strasbourg Hemicycle on Wednesday marked a radical shift with a speech full of European enthusiasm. So much so that several spokespersons, even from rival groups, appreciated this tone of defense of Europe, which is increasingly less common. Sánchez aimed to focus the debate on defending the European Union against totalitarianism and the extreme right, and received widespread support. However, the session became much more contentious as the issue of Catalonia came to the fore. Several MEPs asked him to do something to free the “procés” prisoners, whom some defined as \"political prisoners.\" Several Catalan pro-independence leaders who are imprisoned are well-known in the European Parliament because they were once members. A number of posters with their photos, splashed in yellow, punctuated the dominant blue of the enormous Strasbourg hemicycle. \\n\\nMORE INFORMATION       \\nApplause for Sánchez, Casado, and Rivera       \\nSánchez will request equality policies and a common unemployment insurance in Europe      \\nThe PSOE tests PP and Cs with motions against sexism throughout Spain  \\n\\nAccompanied by Josep Borrell, who presided over this Parliament (2004-2007), Sánchez did not want to talk about Catalonia — although he was forced to do so — but rather about Europe and the success of anti-Europeanism. “For Europe to protect us, it is our duty to protect Europe,” the president proclaimed as a key idea. Sánchez delivered several messages against the extreme right, precisely on the same day when a government in Andalusia was being formed with the support of Vox, which was mentioned in speeches by several MEPs, not only the Spanish ones. \"Forgetting history is a luxury we cannot afford. We are facing an authoritarianism that thrives on invented nostalgia. There is no worse nostalgia than longing for what never happened,\" he cited, referring to Joaquín Sabina. \"In the face of regression, progress. The past will never be the future of our societies; it is a place from which to learn from our mistakes. They want to destroy the EU because of the values it upholds. At specific moments in our history, to resist is to advance,\" Sánchez asserted, referring to his political biography, which began with a job for the UN in Bosnia, to explain his Europeanism. \"Peace and democracy cannot be taken for granted. I saw it in Sarajevo. The rise of these anti-European forces threatens our integration project and influences the agenda. I urge us not to be dragged by this force and its siren songs. They only pursue the goal of destroying Europe. I am not worried about the far-right but about how it is influencing the discourse of parties that previously wanted to strengthen the EU. Therefore, I propose protecting Europe so that Europe can protect our citizens,\" he concluded.'),\n",
       " Document(page_content='The spheres are made of carbon steel, and three of them are covered with thermal insulation (primarily polyurethane foam, a common insulator even in construction) to allow for the storage of refrigerated propane inside. These three insulated spheres will be scrapped due to the high cost of dismantling their insulation, while the others are being dismantled and transported to a company in another country. According to Repsol, the dismantling work is being carried out following the group\\'s safety standards by a specialized Spanish company. The team responsible for these tasks consists of a minimum workforce of four people, including a safety manager and a site manager, though for special operations the team is reinforced with more experienced personnel in the use of machinery and the removal of asbestos cement, among other tasks.\\n\\nA prestigious engineering firm is in charge of safety coordination and supervision, while Repsol personnel from the Escombreras LPG plant (Murcia) and engineering and maintenance supervisors oversee the work and material removal.\\nEight people, five Romanians, two Spaniards, and one Bulgarian, have been arrested in a single day after being caught red-handed attempting to steal copper cable at two locations in the city of Alicante. According to a statement from the National Police Corps, these men were found with nearly 90 meters of cable and numerous tools, including two sledgehammers, three crowbars, four hoes, three pliers, two screwdrivers, a pickaxe, a shovel, and a generator.\\n\\nThe first incident occurred on the 15th when five men (one of them a minor) were arrested while inside a warehouse in the industrial area of Aguamarga, digging a trench in the parcel\\'s ground to access and steal copper cable. At that moment, they had cut about one and a half meters of the cable and had an additional seven meters of trench exposed. They were found with approximately 40 meters of copper cable and numerous tools, such as two sledgehammers, three crowbars, four hoes, pliers, a pickaxe, a shovel, and a generator.\\n\\nJust a few hours later, another three individuals were caught by a police patrol stealing copper in several buildings under construction in Cabo de las Huertas. Upon noticing the police presence, the suspects attempted to flee but were immediately intercepted and arrested. They were found with various tools used to cut and prepare the copper cable for subsequent sale and about 50 meters of copper cable.\\n\\nAll the detainees have been put at the disposal of the Alicante duty court, except for the minor who was released.\\n\"We are in one of the provinces with the most castles in Spain, but also in one where restoration support is lacking.\" These words were spoken many years ago by the late professor José Luis García de Paz, a heritage researcher and one of the leading specialists in this field. It remains a statement that reflects the neglect in which a large part of the historical and artistic heritage of the province of Guadalajara lies.\\n\\nThe Parador of Sigüenza, established in 1976 in the castle of this town; the Museum of the Alcarria Journey, located in the Templar castle of Torija; the Casa del Doncel, in Sigüenza; the Romanesque church of Labros, in the Lordship of Molina; the Tower of Aragon in Molina; or the walls of Atienza, rehabilitated with state funds, are some exceptions in the catalog of restored historical assets in Guadalajara. Also included are the rural Romanesque hermitages, especially those in the Sierra Norte, and other singular monuments such as the castle of Jadraque, the Ducal Palace of Pastrana, the Romanesque churches of Brihuega, the cathedral of Sigüenza, or the historic center of Hita in the heart of the Alcarria. However, due to Guadalajara\\'s dense history, the province\\'s heritage encompasses dozens of architectural assets, especially in small villages, still awaiting attention from administrations.\\n\\nOrtega y Gasset, who explored the Castile of Guadalajara in the early 20th century and documented the monuments possessed by its villages, admired something in the Germans that he missed in Spain: respect for the past. Little progress has been made since then, as evidenced by the \\'Red List of Heritage,\\' annually updated by the Hispania Nostra association. Castilla-La Mancha is, after Castilla y León, the autonomous community with the most monuments on this list: 72 in total, of which 23 are in Guadalajara. These include significant sites such as the castles of Galve de Sorbe, Pelegrina, or Riba de Santiuste in the Sierra Norte, but also the church of San Francisco de Atienza – the only example of English Gothic in Guadalajara – and the monasteries of Bonaval in Retiendas; Santa María de Óvila in Trillo; San Salvador in Pinilla de Jadraque; and Sopetrán in the heart of the Alcarria.'),\n",
       " Document(page_content='Professor Andrew Chamberlain, from the University of Manchester and co-author of the work, states that \"chalk is not the most suitable material for making measuring equipment and it is thought that the drums may be replicas of the original \\'working\\' standards carved from wood.\" However, this wood does not survive in most Neolithic archaeological sites, and no wooden measuring devices have been found in prehistoric Britain. \"The existence of these measuring devices therefore implies an advanced knowledge of prehistoric geometry and the mathematical properties of circles,\" concludes Chamberlain.\\nLuciano Mutasi Mba, known as Lucho to football fans, is still wondering why it happened to him last Sunday. The question spins around in his head with no resolution in sight. \"Why is being black, at the doorstep of the second decade of the 21st century, a reason to insult someone?\" he asks. The thing about irrational issues is that they never have an answer. Last Sunday, a group of CD Buñol fans targeted him for the color of his skin during the match against his team, Segorbe. He endured the insults for over 45 minutes. \"As soon as the second half started, with the score at 2-2, after competing for the ball on the wing, they began to call me \\'shitty black\\' and similar things, and they didn\\'t stop,\" recalls Lucho, a 28-year-old Guinean player signed by Segorbe last month. He had been playing in Malta\\'s first division. This week, CD Buñol was fined 1,500 euros by the RFEF Competition Committee for the racist insults directed at Lucho. Referee Yerai Fermosell Pérez documented everything in the match report. \"When they were insulting me, I put my finger to my ear, looking at the linesman to ask if he was hearing it. He said yes, and at least then I could be somewhat at ease,\" Lucho said. Specifically, the referee noted: \"During the second half of the match, more precisely between the 70th and 80th minutes and at the end of the game (identified as CD Buñol supporters by their chants and attire), a section of the audience repeatedly shouted \\'nigger, nigger\\' and \\'shitty black\\' whenever CD Segorbe player Luciano Mutasi Mba played the ball, aiming to offend the player.\" The 1,500 euros fine is the minimum amount stipulated by the regulations. Lucho disagrees with the punishment. He believes the club is not at fault. \"What they should have done is stop the match and call the police. Then, one by one, identify those who were insulting me,\" he explains. According to the Segorbe player, around 50 people ended up insulting him. \"Every time I touched the ball, they insulted me. They said \\'black son of a bitch, go home\\' or \\'look black, what are you doing here?\\'\" Lucho, who plays as a central defender or midfielder, knows Spanish football well. He has played in the Canary Islands\\' third division and the Aragonese division. \"They had never been racist with me here, nor in Malta, where many foreigners play.\"\\nThe sniper arrested and imprisoned for his intention to kill the Prime Minister, Pedro Sánchez, was hired as a security guard to \"exceptionally\" reinforce the surveillance of the Telecommunications Center (CTTI) of the Generalitat days before October 1st and until the December 21st elections. According to information from Rac-1 and confirmed by the Department of Digital Policies in a statement, Manuel Murillo was requested by the private company responsible for CTTI security to be part of the security reinforcement team for the organization from September 19th, when the Civil Guard searched several public buildings in an operation to prevent the referendum, until December 21st, the date of the parliamentary elections. The sniper, who is currently in pre-trial detention, was never part of the fixed security teams for the Telecommunications and Information Technology Center building, which has been managed by the company Enerpro SL since 2007, following a tender. Specifically, according to the Department of Digital Policies, Murillo was part of a security team contracted due to construction work in the building adjacent to the CTTI, which required additional reinforcement to ensure access and the flow of people to the premises. \\n\\nDuring those days, the Civil Guard visited the CTTI several times in search of information to try to abort the logistical support for October 1st. Murillo, the son of the last Francoist mayor of Rubí (Barcelona), always worked at the CTTI during night shifts as part of the reinforcement team, according to the Generalitat.'),\n",
       " Document(page_content='\"The century of women\" Sánchez introduced several concrete proposals to advance the European Union, especially a novel one on gender equality. \"Spain formed the government with the highest number of women in the EU. A milestone. I propose that the EU adopt a binding gender equality strategy to combat inequality. It is the century of women,\" he explained. He also supported the creation of \"a true European army.\" \"We must show that we are a soft power by choice, not by weakness.\" Additionally, he called for \"eliminating the unanimity rule in foreign policy,\" advocated for more fiscal integration, a stabilization mechanism, and, above all, a European unemployment insurance. \"We must strengthen the euro before the next crisis,\" he proposed. The Spanish president also pushed for a global migration approach, offering a fervent defense of immigration, which was highly criticized by some MEPs from ultra-right groups. Many parliamentarians wanted to speak, although the chamber was half-empty, as is usual in this type of parliamentary address by presidents, and only filled up at the end of the debate when MEPs came in en masse because voting was scheduled right after Sánchez finished, the only time the enormous chamber is fully occupied. The debate heated up significantly around the issue of Catalonia. After resounding applause for his pro-European message, Sánchez received sharp blows from both sides, for governing with the support of pro-independence parties and for presiding over a country that, according to some MEPs, has \"political prisoners.\" Manfred Weber, spokesperson for the EPP, opened the criticism: \"You are a leader committed to Europe. This is good news for Spain. We are all in the same boat, the extreme right is a danger, but extremists have no color. Your government could not exist without the extreme left and the separatists.\" The popular Esteban González Pons went much further. “You can’t say ‘I will never negotiate with extremists’ when you are in government with the independents. You couldn’t defend the unity of Spain here with conviction. You failed here today. It pains me, but I endure it,\" he proclaimed. Several socialist MEPs like Elena Valenciano or José Blanco reproached the former PP spokesperson for the \"disloyalty\" of making that speech in front of the president after the PSOE supported Mariano Rajoy\\'s government in the most difficult moments of the independence challenge. The socialists backed Rajoy’s government in October 2017 in applying Article 155 of the Constitution in Catalonia, following Carles Puigdemont\\'s declaration of independence.\\n\\nSánchez tried to avoid responding to the harshest speeches questioning Spanish democracy, talking about \"political prisoners,\" and demanded that he work for their release: from José Bové, a historic representative of French farmers, to the more moderate Greens\\' spokesperson Ska Keller, who did not call them \"political prisoners\" but did say that \"there are former members of the European Parliament imprisoned for something that is not considered a crime either in Germany or Belgium.\" Sánchez made a general appeal for dialogue and asked the independence movement, with representatives in the European Hall like Ramón Tremosa, to admit that they do not have a majority to impose their project on the rest of the Catalans.'),\n",
       " Document(page_content='\"Wouldn\\'t it be easier for us progressives to agree among ourselves?\" asked the leader of Podemos, citing the tripartite coalition in Catalonia, which once included the PSOE and ERC, acknowledging the plurinationality of the State. Specifically regarding Catalonia, he insisted that he does not agree with a unilateral referendum because it does not guarantee the right to decide and advocated for the plurinational model of the State to have \"legal translations.\" In his opinion, there are democratic solutions to the Catalan problem within the framework of the law, but negotiation is necessary, and he recalled that the 1978 Constitution already recognizes that Spain has regions and nationalities. \"United under different rules, we can be stronger,\" insisted Iglesias, who accused the PP of being the largest \"manufacturer of independentists\" with its unyielding policies.\\nTom MacMaster, the 40-year-old American who has confessed to being the author of the blog \\'A Gay Girl in Damascus,\\' defended on Monday the creation of this online diary about the lack of freedom in Syria and the repression by security forces to make people pay attention to the facts instead of the statements by leaders. MacMaster, who is studying for a master\\'s degree at the University of Edinburgh, created this blog in February, supposedly written by Amina Abdallah Araf al Omari, to explain \"what it\\'s like to be a lesbian here\" and garnered many followers in recent months with the rise of protests. Amina described how she participated in protests in the country, her forbidden loves, and even her escapes from persecution by security forces. MacMaster explained to the BBC that a few years ago, when he discussed the Middle East in the United States and provided real data and opinions, he was labeled as anti-American and anti-Jewish. \"So I made up a name through which I could speak to focus on the real issues,\" he indicated. MacMaster pointed out that he wanted people to pay attention to the facts and not to the individuals and leaders making the statements. \"From the very beginning, I never imagined getting as much attention as I have,\" he declared. \"When I started, I thought I would have four, five, maybe ten readers,\" he added. MacMaster acknowledges that his work has made the situation more difficult for Syrian activists. \"However, the truth is that I have been in contact with many people inside Syria, and I have followed things very closely,\" he assured.'),\n",
       " Document(page_content='The city remains with the Palacio del Infantado, Salón Chino, the chapel of Luis de Lucena, the Palacio de Antonio de Mendoza, and the Torreón del Alamín. García de Paz documented the destruction inflicted upon part of Guadalajara\\'s heritage during the Civil War. A large part of the Municipal Archive of Zorita de los Canes was used to wrap groceries in Pastrana and its region\\'s shops, while in the Town Hall of Horche, ancient documents were discarded due to lack of storage space, including the town charter awarded in the 16th century. Artistic pieces from churches and castles were sold, and significant parts of the provincial monumental inventory were looted. The most iconic example is the 1931 transfer of part of the Óvila monastery to the USA, following the interventions of press magnate William Randolph Hearst, known for fabricating news during the Spanish-American War in Cuba. Óvila\\'s remains are still in the USA today.\\n\\nGuadalajara is a province where over 80% of municipalities have fewer than 1,000 residents. Despite this, almost all preserve monuments that are either legally protected with some artistic designation or are considered part of the province\\'s artistic reserves. Some of these jewels are paradigmatic of the poor condition in which Guadalajara\\'s architectural heritage remains. \\n\\nThe convent of San Antonio de Mondéjar and the castle of Zorita de los Canes, despite being national monuments, are not in optimal conservation states. The recent blockage by Podemos of the regional accounts for this year may suspend the investments the Junta had committed to rehabilitating two other singular heritage buildings, notably the monastery of Bonaval. Founded in 1164 and located in Retiendas, the monastery of Santa María de Bonaval remains in poor condition with only parts of its church surviving.\\n\\nThe Platform \\'Save Bonaval\\' has garnered the regional administration\\'s attention with their efforts to recover the building. The Junta committed to a comprehensive rehabilitation plan for the monastery, budgeted at 3 million euros across several phases. The first phase, which includes archaeological studies, site cleaning, and structural consolidation, is slated to begin this summer with nearly 400,000 euros in funding. Culture Counselor Ángel Felpeto mentioned that the intervention project is in the \"contracting\" phase and announced that guided public visits will be possible during the works to inform citizens about the conservation efforts.\\n\\nThe project to restore Don Juan Manuel\\'s castle in Cifuentes coincides with the 700th anniversary of its acquisition by the noble and writer. The Junta aims to rehabilitate this cultural asset through the Youth Guarantee Plan, which blends employment generation and heritage recovery. Directed at unemployed youth between 16 and 29, the 18-month employment workshop focuses on the fort\\'s sanitation and partial rehabilitation with 400,000 euros in funding.\\n\\nDeputy Mayor of Cifuentes, Marco Antonio Campos, believes the recent veto on regional budgets should not affect these plans. \"The training school project is already granted, and the rehabilitation funds for the castle are European,\" he says. Most of the project’s budget comes from the European Social Fund, which aims to integrate unemployed and unqualified youth into the labor market. The most endangered part of the structure is its keep, which is cracked and at risk of collapse. The municipality is seeking funding through the rural development plan to undertake necessary consolidation works.\\n\\nThe Castle of Cifuentes Association was founded in 2016 to advocate for the fortress\\'s recovery. President José Luis Poza highlights their efforts to secure financing to restore the castle, with immediate goals of making it a visitable ruin. The necessary investment to repair the keep\\'s threatening crack is around 100,000 euros.\\n\\nThe deplorable state of Villaescusa de Palositos\\' heritage, in the Alcarria Baja region, is iconic of the abandonment faced by many monuments in Guadalajara. Now uninhabited, Villaescusa treasures a 13th-century Romanesque church, declared a Cultural Interest Asset in 2012. Ownership by the Sigüenza Diocese and inclusion in the Romanesque Plan of Guadalajara during Barreda’s government have not prevented its current semi-ruin state. Conflict dates back to the 1970s when Villaescusa de Palositos became private property and was fenced off for hunting. Public access is restricted, preventing passage along historically significant routes like the Camino Real de Peralveche, part of the Santiago’s Way through Vías de la Lana.\\n\\nThe Friends of Villaescusa de Palositos Association has long demanded the consolidation of the crumbling church and reopened paths. They experienced government inaction during Cospedal\\'s mandate, but under Page’s administration, the provincial delegate pledged to address these issues. However, the association has received no follow-up from the Castilla-La Mancha Government.'),\n",
       " Document(page_content='With the eleven arrests, police consider the clan dismantled, noting an increase in their professionalism and danger, as evidenced by their possession of high-power firearms. Police sources highlighted that the clan openly displayed the substantial profits from their activities, showcasing luxury cars, jewelry, and valuable items. Of those arrested, six have already been remanded in custody by the judicial authority.\\nThe Court of First Instance No. 12 of Valencia has once again summoned PP deputy Esteban González Pons for a conciliation act on July 11, following a lawsuit filed against him by the Platform of People Affected by Mortgages (PAH) related to the protest that took place at his residence in 2013. This is the second summoning for this issue—in which the PAH accuses the deputy of lying about the details of the protest he experienced—as the first one took place on June 12 and had to be suspended because González Pons’s summons was not properly recorded. In the new proceeding, to which Europa Press has had access, the magistrate has scheduled another conciliation act for July 11 at 10:00 AM and has agreed to send a summons notice to the \\'popular\\' deputy in a sealed envelope.\\n\\nConcurrently with this proceeding, the platform, represented by attorney Ricardo Cano, submitted a request to the court on Wednesday to avoid further suspensions by also sending the summons to González Pons\\'s \"theoretical usual place of employment, which is the Congress of Deputies,\" besides his home address. They mention that the Congress itself \"has notification protocols for deputies and can ensure his attendance at the next conciliation act as agreed.\"\\n\\nRegarding the suspension of the first act, the PAH emphasizes in their document that González Pons, \"demonstrating his civic spirit and willingness to cooperate with the Administration of Justice,\" allowed the notification at his home to \"expire,\" despite the postal notice.\\n\\nSince May, the platform submitted the lawsuit to the Registry Office of the City of Justice of Valencia in mid-May to schedule a conciliation act with González Pons, thus giving him the \"opportunity\" to retract his statements regarding the protest. If the deputy decides not to retract, the PAH has already announced they will file the corresponding lawsuit.\\n\\nIn the document submitted to the court, the PAH stated that González Pons, \"taking advantage of his status as a public political figure and with the intention of diverting attention from his personal involvement in the \\'Nóos case\\' scheme,\" contacted various debate programs in the media and made numerous statements \"to denigrate the people who participated in the protest around his home, and the PAH in general.\"'),\n",
       " Document(page_content='These treasures date back more than eight centuries and are unanimously valued from an artistic standpoint, yet they are crumbling. Due to its border location, Guadalajara boasts more castles and picotas, the traditional pillars found in plazas symbolizing township. \"The problems with conserving Guadalajara\\'s heritage are mostly common with other provinces of Castilla-La Mancha: a wealth of heritage, sparse population, and limited resources to maintain both without regional, state, or European aid,\" wrote García de Paz in the magazine \\'Añil\\' in 2005.\\n\\nAntonio Herrera Casado, the official chronicler of the province, emphasized in \\'El Hexágono de Guadalajara\\': \"Something has happened in the minds of Spaniards for a medieval castle to be torn down or a book-worthy popular architecture building to be razed, and nothing to happen. What\\'s occurred is the devaluation of \\'old things,\\' now labeled as outdated, in an educational system that prioritizes interculturality and the magical gadgets of \\'new technologies.\\'\"\\n\\nThe province of Guadalajara has over fifty castles, most in poor condition, despite being legally protected as declared Assets of Cultural Interest (BIC). Additionally, the ruin of the San Antonio de Mondéjar monastery, the collapse of the Bonaval monastery, the abandonment of heritage in Villaescusa de Palositos, or even the dire state of the Alcázar in the provincial capital must be mentioned. Both the State Heritage Law of 1985 and the regional regulation, updated in 2013, oblige the owner of a historical asset, whether public or private, to safeguard, conserve, maintain, and under no circumstances, destroy it. However, the Administration – in this case, the regional government responsible for heritage matters – lacks the tools to effectively enforce the current legislation.\\n\\n\"The problem with heritage laws is that they are well-drafted and reflect the aspirations of heritage conservation, but there are no legal mechanisms to enforce them,\" states Raúl Conde, journalist, president of the Castle of Galve Association, and co-author, with ethnologist José Antonio Alonso, of \\'The Red List of Architectural Heritage of the Sierra de Guadalajara,\\' published by the Serranía Association of Guadalajara.\\n\\nThe historian Juan Antonio Gaya Nuño highlighted more than four decades ago the impact of the 20th century, especially in the wake of the Civil War, on the destruction of heritage, but stressed that what was destroyed during the fratricidal conflicts of the 19th and 20th centuries \"was notably less than what was lost in a century and a half of peace, in full awareness that it was an attack.\"\\n\\nIn Guadalajara\\'s capital, we can cite the cases of the houses of Cardinal Mendoza, the tower of San Bernardo, the Piety, and Santiago\\'s church. Another emblematic case showing perpetual neglect of heritage is the Palacio del Infantado, the most recognizable monument in Guadalajara. This building was burned down during an air raid on December 6, 1936. The then provincial chronicler, Francisco Layna Serrano, fervently requested its reconstruction post-war. Unfortunately, the city chose to rebuild the bullring before undertaking the Infantado\\'s restoration, which began in 1961, a quarter-century after the Civil War ended. By 2003, dampness began to appear, and today, while the façade and Patio de los Leones are well-preserved, the rest of the complex remains in poor condition despite initiatives to present Guadalajara\\'s candidature for UNESCO World Heritage status.\\n\\nThe degradation of Guadalajara\\'s historic center is not new. Today, the controversy revolves around the proliferation of vacant lots in the city\\'s core and the neglect of its oldest buildings and remains. This mistreatment is long-standing. Renowned architect Fernando Chueca Goitia highlighted in his work \\'The Destruction of the Urban Legacy,\\' published in 1973, that the city of the Mendozas \"has suffered more misfortunes than most\" due to the \"assault of the urban colossus that is Madrid.\" Chueca viewed this \"urban explosion\" as a \"pure disaster.\" Historically, Guadalajara had 52 palaces, 15 convents or monasteries, and many churches and hermitages. \"Guadalajara, alongside Soria, Valladolid, and Murcia, holds the unfortunate record for urbanistic destruction,\" Chueca Goitia told El País in 1977. Little has improved since then.')]"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "k_results = elastic_vector_search.similarity_search(query, k=10)\n",
    "k_results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1ecaefc7-ca66-4e8d-bb25-0349c2e9bce6",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
